package web;

import pojo.Brand;
import service.BrandService;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet("/add")
public class addServlet extends HttpServlet {

    BrandService brandservice = new BrandService();
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
int i;

      request.setCharacterEncoding("utf-8");
        String brand_name = request.getParameter("brand_name");
        String company_name = request.getParameter("company_name");
        String ordered = request.getParameter("ordered");
        String description = request.getParameter("description");
        Integer status = Integer.parseInt(request.getParameter("status"));

        Brand brand = new Brand();
        brand.setBrand_name(brand_name);
        brand.setCompany_name(company_name);
        brand.setDescription(description);
        brand.setOrdered(ordered);

        brand.setStatus(status);


        brandservice.insert(brand);
        request.getRequestDispatcher("/selectAllServlet").forward(request,response);


    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    doGet(request,response);
    }
}
